package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersPaymentDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderMapper {

    void insert(Orders order);

//    @Select("select estimated_delivery_time from orders where number = #{orderNumber}")
//    String getEstimateDeliveryTime(String orderNumber);

    @Update("update orders set pay_method = 1,pay_status = 1,status = 2 where number = #{orderNumber}")
    void payment(OrdersPaymentDTO dto);

//    @Update("update orders set pay_method = 1,pay_status = 1,status = 2 where number = #{orderNumber}")
//    void paymentTest(Orders order);

    /**
     * 分页条件查询并按下单时间排序
     * @param ordersPageQueryDTO
     */
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 根据id查询订单
     * @param id
     */
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);


}
